<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:67:"C:\wamp64\www\tp\public/../application/index\view\detail\index.html";i:1527679222;}*/ ?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="/static/bootstrap.css">
<script src="/static/jquery.js"></script>
<script src='/static/bootstrap.js'></script>
<style type="text/css">
.caption p{
   display: inline-block;
}
.judge{
    position: fixed;
    top:300px;
    left:600px;
    width: 400px;
    height: 300px; 
    padding: 15px;
    display: none;
}
</style>
</head>
<body>
  <div class='container'>
    <div class="row">
    <h2 class="page-header">
    信息详情
    <span class='label pull-right'><a href="<?php echo url('index/index/index'); ?>">首页</a></span>
    </h2>
       <div class="col-md-4 bg-info">
           <div class="thumbnail " style="margin-top: 10px;">
               <img src="/uploads/<?php echo $message['image']; ?>" alt="发布人个人头像" width="100%" class='img-rounded'>
               <div class='caption' style="font-size: 25px;">
                   <div style="margin-bottom: 15px;">
                       <mark>发布人:</mark>
                       <p class='text-right pull-right' style=""><?php echo $message['uname']; ?></p>
                   </div>
                   <div style="margin-bottom: 15px;">
                       <mark>email:</mark>
                       <p class='text-right pull-right' style=""><?php echo $message['email']; ?></p>
                   </div>
                   <div style="margin-bottom: 15px;">
                       <mark>tel:</mark>
                       <p class='text-right pull-right' style=""><?php echo $message['tel']; ?></p>
                   </div>
               </div>
           </div>
       </div>        
       <div class="col-md-5 bg-success" style="min-height: 451px;">
            <div class='caption' style="font-size: 25px;">
                   <h2 class="page-header text-center">信息内容</h2>
                   <div style="margin-bottom: 15px;">
                       <mark>信息名:</mark>
                       <p class='text-right pull-right' style=""><?php echo $message['mname']; ?></p>
                   </div>
                   <div style="margin-bottom: 15px;">
                       <mark>发布时间:</mark>
                       <p class='text-right pull-right' style="">
                         <?php echo date('y-m-d h:i',$message['create_time']); ?>
                       </p>
                   </div>
                   <div style="margin-bottom: 15px;">
                       <mark>简介:</mark>
                       <p class='text-right pull-right' style=""><?php echo $message['des']; ?></p>
                   </div>
            </div>
       </div>
       <?php if($message['status'] == 0): ?>
       <div class="col-md-3" style="margin-top: 150px;">
            <div class='thumbnail' style="font-size: 25px;background: #E0FFFF;">
                   <p>如果您对此单有兴趣：请下订单,我们会尽快通知对方与你联系</p>
                   <a class="btn btn-danger btn-block" id='deal' href="<?php echo url('detail/dingdan',['mid'=>$id,'xid'=>$uid]); ?>" >
                       下订单
                    </a>
            </div>
       </div>
       <?php endif; ?>
    </div>
    <div class="row">
        <h1 class="page-header">精彩评论<button id='add' class="btn btn-primary pull-right">添加评论</button></h1>
        <?php if(is_array($judge) || $judge instanceof \think\Collection || $judge instanceof \think\Paginator): $i = 0; $__LIST__ = $judge;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$judge): $mod = ($i % 2 );++$i;?>
        <div class='media'>
             <div class='media-left'>
              <div class='media-object'>
               <img src="/uploads/<?php echo $judge['image']; ?>" width='150px'>
              </div>
            </div>
            <div class="media-body">
             <h1 class='media-heading'><?php echo $judge['jname']; ?></h1>
             <p class='text-danger'><?php echo $judge['content']; ?></p>
            </div>
            <div class='media-right'>
              <span class='badge zan'  num="<?php echo $judge['id']; ?>" >赞<strong ><?php echo $judge['zan']; ?></strong></span>
            </div>
        </div>
        <?php endforeach; endif; else: echo "" ;endif; ?>
    </div>
  </div>
  <div class="judge bg-danger">
      <h3 class="page-header" >添加评论<span class='close' style="font-size:40px;">&times;</span></h3>
         <textarea name="content" id="" cols="48" rows="6"></textarea>
         <button class='btn btn-primary pull-right' id='submit'  uid="<?php echo $uid; ?>">submit</button>
  </div>
  <footer style="margin-bottom: 50px;
               margin-top: 50px;
               left: 400px;">
    <p class='text-center bg-success ' style="font-size: 25px;"><span class='glyphicon glyphicon-plane'></span><br><mark>www.powerli.xyz</mark></p>
</footer>
</body>
<script>
//添加评论
$('#add').click(function(){
    $('body').css({'background':'#EAEAEA'});
    $('.judge').slideDown();
});
$('.close').click(function(){
    $('.judge').slideUp();
});
//点赞和取消点赞自动刷新
$('.zan').bind('click',function(){
    obj=$(this);
    if ((typeof($(this).data('num'))=='undefined')||(obj.data('num')==0)) {
      $.post("<?php echo url('detail/zan'); ?>",{'id':obj.attr('num')},function(e){
          if(e==1){
             zan=obj.children().html();
             obj.children().html(Number(zan)+1);
             obj.css({'background':'#ccc'});
             obj.data('num',1);
          }
      }); 
    }else{
       $.post("<?php echo url('detail/dzan'); ?>",{'id':obj.attr('num')},function(e){
          if(e==1){
             zan=obj.children().html();
             obj.children().html(Number(zan)-1);
             obj.css({'background':'#4D4D4D'});
             obj.data('num',0);
          }
      });
    }
});

//将评论插入数据库并显示
$('#submit').click(function(){
  val=$(this).prev().val();
  id=<?php echo $id; ?>;
  uid=<?php echo $uid; ?>;
  $(this).parent().hide();
  data={'id':id,'uid':uid,'content':val};
  $.post("<?php echo url('detail/judge'); ?>",data,function(e){
     if(e==1){
       alert('success');
       location.reload();
     }else{
       alert('请先登录');
     }
  });
});

//下订单
// $('#deal').click(function(){
//    x=confirm('确定要下订单吗？');
//    if(x){
//      mid=<?php echo $id; ?>;
//      xid=<?php echo $uid; ?>;
//      data={'mid':mid,'xid':xid};
//      $.post("detail/dingdan",data,function(e){
//         if(e==1){
//           alert('success');
//         }if(e==0){
//           alert('error');
//         }
//      })
//    }
// });
</script>
</html>